<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-if 示例</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
</head>

<body>

    <div id="app">
        <button @click="toggleVisibility">今年刚满十八岁</button>

        <!-- 只有当 isVisible 为 true 时，div 会被渲染 -->
        <div v-if="isVisible">
            <img src="./images/1.jpg" />
        </div>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                isVisible: true // 初始值为 true，意味着段落会显示
            },
            methods: {
                toggleVisibility() {
                    this.isVisible = !this.isVisible; // 切换 isVisible 的值
                }
            }
        });
    </script>

</body>

</html>